import {OnInit, Component, ViewChild} from "@angular/core";
import {Observable} from "rxjs";

@Component({
  selector: 'rx-searching',
  templateUrl: 'rx-searching.component.html'
})
export class RxSearchingComponent implements OnInit {
  @ViewChild("text") public text
  private subs_

  ngOnInit(): void {
    this.subs_ = Observable.fromEvent(this.text.nativeElement, 'keyup')
      .debounceTime(250)
      .pluck('target', 'value')
      .switchMap(url => Observable.of(`http://localhost:4200/${url}`).delay(500))
      .subscribe(console.log)
  }
}
